let path = require('path');

const NodeConfig = {
    mode: 'development', // production
    entry: path.join(__dirname, 'main.ts'),
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: 'dist.node.js',
        libraryTarget: "commonjs",
    },
    resolve: {
        extensions: [".ts", ".js"]
    },
    module: {
        rules: [
            {
                test: /\.ts$/,
                use: 'ts-loader',
                exclude: /node_modules/
            },
        ]
    },
    target:'node',
};
const BrowserConfig = {
    mode: 'development', // production
    entry: path.join(__dirname, 'main.ts'),
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: 'dist.web.js',
        libraryTarget: "umd",
        library:"myTools",
    },
    resolve: {
        extensions: [".ts", ".js"]
    },
    module: {
        rules: [
            {test: /\.txt$/, use: 'raw-loader'}, // for test
            {test: /\.css$/, use: ['style-loader', 'css-loader']}, // for test
            {
                test: /\.ts$/,
                use: 'ts-loader',
                exclude: /node_modules/
            },
        ]
    },
    target:'web',
    node:{
        fs:'empty'
    }
};

module.exports = [NodeConfig,BrowserConfig];
